check surface status after ceating a pdf. Avoids crashing when the target
authorHans Breuer <hans@breuer.org>
Fri, 13 Jun 2008 08:36:26 +0000 (08:36 +0000)
committerHans Breuer <hans@src.gnome.org>
Fri, 13 Jun 2008 08:36:26 +0000 (08:36 +0000)
2008-05-23  Hans Breuer  <hans@breuer.org>

* gtk/gtkprintoperation.c : check surface status after ceating a pdf.
Avoids crashing when the target can not be written, bug #537685

* gdk/win32/gdkdisplay-win32.c : runtime linking of ProcessIdToSessionId

* gtk/gtkfilesystem.c : variadic macros are not supported with c89 and
it was not needed here anyway.

svn path=/trunk/; revision=20370

ChangeLog
gdk/win32/gdkdisplay-win32.c
gtk/gtkfilesystem.c
gtk/gtkprintoperation.c

index 1a50541dce0d5a367d7d5b991b610eb764094bac..c35c546c70c391c545816fb73b162636c33360a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-05-23  Hans Breuer  <hans@breuer.org>
+
+       * gtk/gtkprintoperation.c : check surface status after ceating a pdf.
+       Avoids crashing when the target can not be written, bug #537685
+
+       * gdk/win32/gdkdisplay-win32.c : runtime linking of ProcessIdToSessionId
+
+       * gtk/gtkfilesystem.c : variadic macros are not supported with c89 and
+       it was not needed here anyway.
+
 2008-06-13 Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkentry.c (gtk_entry_draw_frame): Fix frame size allocation.
index 43dcb745754cc648f40b91f95b34b9ac0461c092..1874c608e9789b3153a8e688e81d366ed5ccd08d 100644 (file)
@@ -241,6 +241,8 @@ gdk_display_get_name (GdkDisplay *display)
   DWORD session_id;
   char *display_name;
   static const char *display_name_cache = NULL;
+  typedef BOOL (* PFN_ProcessIdToSessionId) (DWORD, DWORD *);
+  PFN_ProcessIdToSessionId processIdToSessionId;
 
   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
   
@@ -275,7 +277,8 @@ gdk_display_get_name (GdkDisplay *display)
        window_station_name = "WinSta0";
     }
 
-  if (!ProcessIdToSessionId (GetCurrentProcessId (), &session_id))
+  processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle ("kernel32.dll"), "ProcessIdToSessionId");
+  if (!processIdToSessionId || !processIdToSessionId (GetCurrentProcessId (), &session_id))
     session_id = 0;
 
   display_name = g_strdup_printf ("%ld\\%s\\%s",
index 027f1bb49cea1434cb5ea749cff93ecf7fb55e55..c78ae77d3898505f68898edf622e41fb70fd4174 100644 (file)
@@ -29,9 +29,9 @@
 
 /* #define DEBUG_MODE */
 #ifdef DEBUG_MODE
-#define DEBUG(x...) g_debug (x);
+#define DEBUG(x) g_debug (x);
 #else
-#define DEBUG(x...)
+#define DEBUG(x)
 #endif
 
 #define GTK_FILE_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemPrivate))
index 3b7bff403d500d49bd5b220830ac7759a52cd1bd..ff0edff6317cc752aa89e9f39200eb5492adf815 100644 (file)
@@ -1840,6 +1840,17 @@ run_pdf (GtkPrintOperation  *op,
   
   surface = cairo_pdf_surface_create (priv->export_filename,
                                      width, height);
+  if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
+    {
+      g_set_error (&priv->error,
+                  GTK_PRINT_ERROR,
+                  GTK_PRINT_ERROR_GENERAL,
+                  cairo_status_to_string (cairo_surface_status (surface)));
+      *do_print = FALSE;
+      return GTK_PRINT_OPERATION_RESULT_ERROR;
+    }
+
+  /* this would crash on a nil surface */
   cairo_surface_set_fallback_resolution (surface, 300, 300);
 
   priv->platform_data = surface;